package com.qq.first_project.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qq.first_project.entity.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qq.first_project.entity.vo.CommentVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Qiu
 * @since 2023-01-30
 */
@Repository
public interface CommentMapper extends BaseMapper<Comment> {
    //添加一个评论
    int saveComment(Comment comment);

    //查询父级评论
    List<Comment> findByParentIdNull(@Param("ParentId") Long ParentId,Long blogId);

    //查询一级回复
    List<Comment> findByParentIdNotNull(@Param("id") Long id,Long blogId);

    //查询二级以及所有子集回复
    List<Comment> findByReplayId(@Param("childId") Long childId,Long blogId);

    //查询所有评论
    IPage<CommentVo> listAll(Page<CommentVo> page, String name);

    //更新评论
    int updateCommentById(CommentVo commentVo);
}
